<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <xi:include href="macros.html" />
  <xi:include href="testmanagement.html" />

  <head py:if="not part">
    <title>Test Detail</title>
    <script type="text/javascript">
    function load_page(id, suffix) {
        var page = "${href.test()}" + "/" + id + "/" + suffix;
        window.location.href = page;
    }
    function post_page(form, id, suffix, query, parent_id) {
        query = query || "";
        jQuery(window).load("${href.test()}" +  "/" + id + "/" + suffix,
                            jQuery(form).serialize() + query);
        return true;
    }
    </script>
  </head>
  <head><title>aaa</title></head>
  <body>
    <div id="detail_content">

  <py:if test="proj">

    <py:if test="not preview and not fmt">
      <div class="top_buttons">
        <input py:if="'TEST_EDIT' in perm" type="button" value="Edit project"
               onClick="load_page($proj.node.id, '$page?fmt=edit')"/>
        <input py:if="'TEST_CREATE' in perm" type="button" value="New test suite"
               onClick="load_page($proj.node.id, 'newsuite')"/>
        <input py:if="'TEST_CREATE' in perm" type="button" value="New test case"
               onClick="load_page($proj.node.id, 'newtestcase')"/>
      </div>
      ${show_project(proj, customfields, preview)}
      ${list_of_attachments(attachments)}
    </py:if>

    <py:if test="fmt == 'edit'">
      <h1>${proj.node.id and 'Edit' or 'Create New'} Test Project</h1>
      <py:if test="preview">
        ${show_project(proj, customfields, preview)}
      </py:if>
      <form id="project_form" method="POST">
        ${show_project_form(proj, customfields)}
        <div class="top_buttons">
          <input type="hidden" name="fmt" value="edit" />
          <input type="button" value="Preview"
            onClick="return post_page('#project_form', $req.args.id, '$page', '&amp;preview=preview')"/>
          <input type="button" value="${proj.node.id and 'Submit changes' or 'Create test project'}"
            onClick="return post_page('#project_form', $req.args.id, '$page', null, null)"/>
        </div>
      </form>
    </py:if>

  </py:if>

  <py:if test="testsuite">

    <py:if test="not preview and not fmt">
    <div class="top_buttons">
        <input type="button" value="Edit" onClick="load_page($testsuite.node.id, '$page?fmt=edit')"/>
        <input type="button" value="Delete" onClick="load_page($testsuite.node.id, '$page?fmt=delete')"/>
        <input type="button" value="New test suite" onClick="load_page($testsuite.node.id, 'newsuite')"/>
        <input type="button" value="New test case" onClick="load_page($testsuite.node.id, 'newtestcase')"/>
      </div>
      ${show_testsuite(testsuite, customfields, preview)}
      ${list_of_attachments(attachments)}
    </py:if>

    <py:if test="fmt == 'edit'">
      <h1>${testsuite.node.id and 'Edit' or 'Create New'} Test Suite</h1>
      <py:if test="preview">
        ${show_testsuite(testsuite, customfields, preview)}
      </py:if>
      <form id="testsuite_form" method="POST">
        ${show_testsuite_form(testsuite, customfields)}
        <div class="top_buttons">
          <input type="hidden" name="fmt" value="edit" />
          <input type="button" value="Preview"
            onClick="return post_page('#testsuite_form', $req.args.id, '$page', '&amp;preview=preview')"/>
          <input type="button" value="${testsuite.node.id and 'Submit changes' or 'Create test suite'}"
            onClick="return post_page('#testsuite_form', $req.args.id, '$page', null, $testsuite.node.parent_id)"/>
        </div>
      </form>
    </py:if>

    <py:if test="fmt == 'delete'">
      <h1>Delete Test Suite: $testsuite.node.name</h1>
      <strong>Are you sure you want to delete this test suite?</strong>
      <div class="top_buttons">
        <form id="testsuite_form" method="POST">
          <input type="hidden" name="fmt" value="delete" />
          <input type="button" value="Cancel" onClick="return load_page($testsuite.node.id, '$page')" />
          <input type="button" value="Delete test suite"
            onClick="return post_page('#testsuite_form', $testsuite.node.id, '$page', null, $testsuite.node.parent_id)" />
        </form>
      </div>
    </py:if>

  </py:if>

  <py:if test="testcase">

    <py:if test="not preview and not fmt">
      <div class="top_buttons">
        <input type="button" value="Edit" onClick="load_page($testcase.node.id, '$page?fmt=edit')"/>
        <input type="button" value="Delete" onClick="load_page($testcase.node.id, '$page?fmt=delete')"/>
      </div>
      ${show_testcase(testcase, customfields, preview)}
      ${list_of_attachments(attachments)}
    </py:if>

    <py:if test="fmt == 'edit'">
      <h1>${testcase.node.id and 'Edit' or 'Create New'} Test Case</h1>
      <py:if test="preview">
        ${show_testcase(testcase, customfields, preview)}
      </py:if>
      <form id="testcase_form" method="POST">
        ${show_testcase_form(testcase, customfields)}
        <div class="top_buttons">
          <input type="hidden" name="fmt" value="edit" />
          <input type="button" value="Preview"
            onClick="return post_page('#testcase_form', $req.args.id, '$page', '&amp;preview=preview')"/>
          <input type="button" value="${testcase.node.id and 'Submit changes' or 'Create test case'}"
            onClick="return post_page('#testcase_form', $req.args.id, '$page', null, $testcase.node.parent_id)"/>
        </div>
      </form>
    </py:if>

    <py:if test="fmt == 'delete'">
      <h1>Delete Test Case: $testcase.node.name</h1>
      <strong>Are you sure you want to delete this test case?</strong>
      <div class="top_buttons">
        <form id="testcase_form" method="POST">
          <input type="hidden" name="fmt" value="delete" />
          <input type="button" value="Cancel" onClick="return load_page($testcase.node.id, '$page')" />
          <input type="button" value="Delete test case"
            onClick="return post_page('#testcase_form', $testcase.node.id, '$page', null, $testcase.node.parent_id)" />
        </form>
      </div>
    </py:if>

  </py:if>

    </div>
  </body>
</html>

